﻿using FreeRedis;

namespace Simple.WebAi.Extensions
{
    /// <summary>
    /// FreeRedis扩展
    /// </summary>
    public static class FreeRedisExtensions
    {
        /// <summary>
        /// 注册FreeSql
        /// </summary>
        /// <param name="services"></param>
        public static void AddFreeRedis(this IServiceCollection services)
        {
            var configuration = services.BuildServiceProvider().GetService<IConfiguration>()!;
            var redisConnectionString = configuration.GetConnectionString("SimpleRedisConnection");

            RedisClient cli = new RedisClient(redisConnectionString);
            cli.Notice += (s, e) => Console.WriteLine(e.Log);
            services.AddSingleton<RedisClient>(cli);
        }
    }
}
